<template>
<div>
    <h1>{{msg}}</h1>
    <h2>学生名称:{{name}}</h2>
    <button @click="sendStudentName">点我显示老王</button>
</div>
</template>

<script>
export default {
  name:'StudentN',
  props:['getStudentName'],
  data() {
    return {
        msg:'你好',
        name: '老王'
    }
  },
  methods:{
    sendStudentName(){
        this.getStudentName(this.name)
    }
  }
}
</script>

<style scoped>
.demo{
  background: blue;
}
</style>